
Framework  sedm.blitz3dogre
Import brl.polledinput
Import brl.random
Import brl.timer

SeedRnd MilliSecs()


AppTitle = "BlitzOgre3D / Blitz3D-like API"

Graphics3D(800, 600)
AmbientLight(0.1, 0.1, 0.1)

SetShadowTechnique(SHADOWTYPE_TEXTURE_MODULATIVE)
SetShadowTextureSize(1024)
setShadowFarDistance(100.0)

Physics()


LoadSkyBox("media.zip/SkyBox.material")

cam = createCamera()

' Fullscreen FX "Bloom"
ScreenFX(cam, "Bloom")

mat = GetBrushByName("Ogre/Compositor/BloomBlend2")	' get the Fullscreen FX Brush
tech = GetBrushTechnique(mat) ' get Brush Technique
pss = GetBrushPass(tech) ' get then Technique Pass
pars = GetPassPars(pss) ' get the GPU FragmentProgramm Parameters of this Pass

SetBrushConstantF(pars, "BlurWeight", 0.3)	' set the Parameter "BlurWeight" to 0.3
SetBrushConstantF(pars, "OriginalImageWeight", 1.0) ' set the Parameter "OriginalImageWeight" to 1.0
	
player	= CreatePivot()
CameraRange(cam, 0.1, 10000)

EntityParent(cam, player)
PositionEntity(player, 0.0, 20.0, -50.0)

l = CreateLight()
PositionEntity(l, 10.0, 100.0, -100.0)

box 	= LoadMesh("media.zip/box.mesh")
ground	= LoadMesh("media.zip/ground.mesh")

DynamicEntity(ground, CS_BOX, 0.0)

PositionEntity(ground, 0.0, 0.0, 0.0)
PositionEntity(box, 0.0, 50.0, 0.0)

EntityShadows(ground, False)


Repeat
	mx = MouseXSpeed()
	my = MouseYSpeed()
	
	If KeyDown(KEY_W) Then MoveEntity(player, 0.0, 0.0, 0.1)
	If KeyDown(KEY_A) Then MoveEntity(player, -0.1, 0.0, 0.0)
	If KeyDown(KEY_S) Then MoveEntity(player, 0.0, 0.0, -0.1)
	If KeyDown(KEY_D) Then MoveEntity(player, 0.1, 0.0, 0.0)
		
	If KeyHit(KEY_SPACE)
		nbox = CopyEntity(box)
		PositionEntity(nbox, Rnd(-5.0, 5.0), 30.0, Rnd(-5.0, 5.0))
		DynamicEntity(nbox)
	End If
	
	If MouseDown(2)
		TurnEntity(player, 0.0, -mx * 0.01, 0.0)
		TurnEntity(cam, -my * 0.01, 0.0, 0.0)
	EndIf
		
	UpdateWorld()
	RenderWorld()
	
Until KeyDown(KEY_ESCAPE)

End
